#ifndef ELEMENTSPIKES_H
#define ELEMENTSPIKES_H

#include "GameElement.h"
#include "AnimationObj.h"
#include "Drawing.h"

struct spikeAnimation:public animationObj{

    spikeAnimation(){

    }


    void render(){
        static GLuint dlID=0;

        glPushMatrix();
        glColor3f(0,0,0);

        glTranslatef(0,-(float)frame/maxframe,0);

        if(!dlID){

            dlID=glGenLists(1);
            glNewList(dlID,GL_COMPILE_AND_EXECUTE);

            for(int i=0;i<3;i++){
                glPushMatrix();
                for(int j=0;j<3;j++){
                Drawing::drawPyramid(0.3,1,0,0,0);
                glTranslatef(0.3,0,0);
                }
                glPopMatrix();
                glTranslatef(0,0,0.3);
            }


            glEndList();

        }else glCallList(dlID);

        glPopMatrix();

        nextFrame();

    }
};

class ElementSpikes : virtual public GameElement
{
    spikeAnimation aniObj;
    int damage;
public:
    ElementSpikes(vector3<int> pos);
    void invokeCollisionEvent(Character*);
    void invokeActivateEvent();
    void invokeUpdateEvent(Character *);
    void activate();
    void deactivate();
    void render();
    void editorModeRender(){render();}
    const char* getName(){return "Spikes";}

    int getDamage(){return damage;}
    void setDamage(int _damage){
        damage=_damage;
    }
};

#endif // ELEMENTSPIKES_H
